home *** CD-ROM | disk | FTP | other *** search
/ Delphi Magazine Collection 2001 / Delphi Magazine Collection 20001 (2001).iso / DISKS / Issue54 / Persist / ddl.sql < prev    next >
Encoding:
Text File  |  2000-01-09  |  4.0 KB  |  153 lines

  1. /*****************************************************************
  2.   Connect to the database
  3. */
  4.  
  5. connect  "adrs.gdb"
  6. user "SYSDBA" password "masterkey" ;
  7.  
  8. /*****************************************************************
  9.   Drop the database
  10. */
  11.  
  12. Drop Database ;
  13.  
  14. /*****************************************************************
  15.   Create a new database
  16. */
  17. Create Database "adrs.gdb"
  18. user "SYSDBA" password "masterkey" ;
  19.  
  20.  
  21. /*****************************************************************
  22.   Connect to the new database
  23. */
  24. connect "adrs.gdb"
  25. user "SYSDBA" password "masterkey" ;
  26.  
  27.  
  28. create domain domain_oid as integer not null ;
  29. create domain domain_type as varchar( 20 ) not null ;
  30.  
  31. create table Next_OID
  32.   ( next_oid domain_oid ) ;
  33.  
  34. insert into next_oid
  35.   ( next_oid )
  36. values
  37.   ( 100 ) ;
  38.  
  39. create table person
  40.   ( oid        domain_oid,
  41.     last_name  varchar( 60 ),
  42.     first_name varchar( 60 ),
  43.     title      varchar( 10 ),
  44.     initials   varchar( 10 ),
  45.     notes      varchar( 250 ),
  46.     primary key ( oid )) ;
  47.  
  48. create table adrs
  49.   ( oid         domain_oid,
  50.     owner_oid   domain_oid,
  51.     adrs_type   domain_type,
  52.     lines       varchar( 180 ),
  53.     state       varchar( 20 ),
  54.     pcode       varchar( 10 ),
  55.     country     varchar( 20 ),
  56.     primary key( oid ),
  57.     foreign key( owner_oid ) references person (oid )
  58.       on delete cascade ) ;
  59.  
  60. create table EAdrs
  61.   ( oid         domain_oid,
  62.     owner_oid   domain_oid,
  63.     eadrs_type  domain_type,
  64.     text        varchar( 60 ),
  65.     primary key( oid ),
  66.     foreign key( owner_oid ) references person (oid )
  67.       on delete cascade ) ;
  68.  
  69.  
  70. insert into person
  71.   ( oid, last_name, first_name, title, initials )
  72. values
  73.   ( 103, 'Hinrichsen', 'Peter', 'Mr', 'P.W.' ) ;
  74. insert into person
  75.   ( oid, last_name, first_name, title, initials )
  76. values
  77.   ( 104, 'Frizel', 'Chris', 'Mr', 'F.' ) ;
  78. insert into person
  79.   ( oid, last_name, first_name, title, initials )
  80. values
  81.   ( 105, 'Barnard', 'Cathy', 'Ms', 'C.' ) ;
  82.  
  83. insert into adrs
  84.   ( oid, owner_oid, adrs_type, lines, state, pcode, country )
  85. values
  86.   ( 106, 103, 'Postal', 'PO Box 429;Abbotsford', 'VIC', '3066', 'Australia' ) ;
  87. insert into adrs
  88.   ( oid, owner_oid, adrs_type, lines, state, pcode, country )
  89. values
  90.   ( 107, 103, 'Business', '23 Victoria Pde;Collingwood', 'VIC', '3066', 'Australia' ) ;
  91. insert into adrs
  92.   ( oid, owner_oid, adrs_type, lines, state, pcode, country )
  93. values
  94.   ( 108, 104, 'Business', 'ITEC UK;9a London Road;Bromley', 'Kent', 'BR1 1BY', 'England' ) ;
  95. insert into adrs
  96.   ( oid, owner_oid, adrs_type, lines, state, pcode, country )
  97. values
  98.   ( 109, 105, 'Business', 'ITEC UK;9a London Road;Bromley', 'Kent', 'BR1 1BY', 'England' ) ;
  99.  
  100. insert into EAdrs
  101.   ( oid, owner_oid, eadrs_type, text )
  102. values
  103.   ( 111, 103, 'Phone: Work', '+ 61 3 9419 6456' ) ;
  104. insert into EAdrs
  105.   ( oid, owner_oid, eadrs_type, text )
  106. values
  107.   ( 112, 103, 'Phone: Mobile', '+ 61 418 108 353' ) ;
  108. insert into EAdrs
  109.   ( oid, owner_oid, eadrs_type, text )
  110. values
  111.   ( 113, 103, 'Phone: Fax', '+61 3 9419 1682' ) ;
  112. insert into EAdrs
  113.   ( oid, owner_oid, eadrs_type, text )
  114. values
  115.   ( 114, 103, 'EMail', 'peter_hinrichsen@techinsite.com.au' ) ;
  116. insert into EAdrs
  117.   ( oid, owner_oid, eadrs_type, text )
  118. values
  119.   ( 115, 103, 'Web', 'techinsite.com.au' ) ;
  120.  
  121. insert into EAdrs
  122.   ( oid, owner_oid, eadrs_type, text )
  123. values
  124.   ( 116, 104, 'Phone: Work', '+44 181 249 0354' ) ;
  125.  
  126. insert into EAdrs
  127.   ( oid, owner_oid, eadrs_type, text )
  128. values
  129.   ( 117, 104, 'Phone: Fax', '+44 181 249 0376' ) ;
  130.  
  131. insert into EAdrs
  132.   ( oid, owner_oid, eadrs_type, text )
  133. values
  134.   ( 118, 104, 'EMail', 'chrisf@itecuk.com' ) ;
  135.  
  136.  
  137. insert into EAdrs
  138.   ( oid, owner_oid, eadrs_type, text )
  139. values
  140.   ( 123, 105, 'Phone: Work', '+44 181 249 0354' ) ;
  141.  
  142. insert into EAdrs
  143.   ( oid, owner_oid, eadrs_type, text )
  144. values
  145.   ( 124, 105, 'Phone: Fax', '+44 181 249 0376' ) ;
  146.  
  147. insert into EAdrs
  148.   ( oid, owner_oid, eadrs_type, text )
  149. values
  150.   ( 125, 105, 'EMail', 'cathyb@itecuk.com' ) ;
  151.  
  152.  
  153.